package com.example.demo.controller;

import com.example.demo.dao.StudentDao;
import com.example.demo.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StudentController {
    @Autowired
    StudentDao studentDao;

    @GetMapping("/test")
    public String t(){
        return "333";
    }

    @GetMapping("/add_student")
    public void addStudent(String name,int age){
        Student student = new Student();
        student.setName(name);
        student.setAge(age);
        studentDao.save(student);
    }

    @GetMapping("/find_all_student")
    public Iterable<Student> find_all_student(){
        return studentDao.findAll();
    }
}
